package Servlets.seeker;

import Dao.SeekerDaoimpl;
import Entity.Seeker;
import Service.SeekerServiceimpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/Ifupdate")

public class Ifupdate extends HttpServlet {

    private static final long serialVersionUID = 1L;


    public Ifupdate() {

        super();
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

// TODO Auto-generated method stub

        request.setCharacterEncoding("UTF-8");

        response.setCharacterEncoding("UTF-8");

        response.setContentType("text/html;charset=UTF-8");

        int sid = (int) request.getSession().getAttribute("seid");
        String userID = request.getParameter("userID");
        String username = request.getParameter("username");
        String education = request.getParameter("education");
        String position = request.getParameter("position");
        String address = request.getParameter("address");
        String phone=request.getParameter("phone");
        String email=request.getParameter("email");
        Seeker myif = new Seeker(username, address, education, position, userID, email,

                sid, phone);

        SeekerDaoimpl ser = new SeekerDaoimpl();
        int n = 0;

        try {

            n = ser.Change(myif);

        } catch (Exception e) {

// TODO Auto-generated catch block

            e.printStackTrace();

        }
        if (n == 0) {

            request.setAttribute("myinfm", myif);

            request.getRequestDispatcher("seekerif.jsp").forward(request, response);

        } else {

            request.setAttribute("myinfm", myif);

            request.getRequestDispatcher("seekerif.jsp").forward(request, response);

        }

    }


    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

// TODO Auto-generated method stub

        doGet(request, response);

    }


}
